package com.gzu.emr.service.impl;

import com.gzu.emr.dto.MedicalRecord;
import com.gzu.emr.mapper.MedicalRecordMapper;
import com.gzu.emr.service.MedicalRecordService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MedicalRecordServiceImpl implements MedicalRecordService {

    @Resource
    private MedicalRecordMapper medicalRecordMapper;

    @Override
    public int addMedicalRecord(MedicalRecord record) {
        int row = medicalRecordMapper.insertMedicalRecord(record);

        return row;
    }

    @Override
    public MedicalRecord selectLastRecordByPatientId(Integer id) {
        if(id >= 0) {
            return medicalRecordMapper.selectLastRecordByPatientId(id);
        } else {
            return null;
        }
    }

    @Override
    public List<MedicalRecord> listRecords() {
        return medicalRecordMapper.listRecords();
    }

    @Override
    public List<MedicalRecord> listRecordsByPatientId(Integer id) {
        return medicalRecordMapper.listRecordsByPatientId(id);
    }

    @Override
    public List<MedicalRecord> listRecordsByPatientName(String name) {
        return medicalRecordMapper.listRecordsByPatientName(name);
    }


}
